#include "ctmapplication.h"

#include <QIcon>
#include <QSystemTrayIcon>
#include <QMenu>

#include <QDebug>

#include "tmiconfactory.h"

int main(int argc, char **argv)
{
	// Create Application object:
	QApplication app(argc, argv);
	// set company name and application Name:
	app.setOrganizationName("TeaMaker");
	app.setApplicationName("TeaMaker Client");
	// don't kill the app when the top-level window closes!
	app.setQuitOnLastWindowClosed(false);
	
	CTMApplication *appObj = new CTMApplication(&app);
	
	// Need a system tray icon: TODO - make this dynamically created in common lib.
	QIcon ic = CTMIconFactory().getAppIcon(QSize(22,22));
	QSystemTrayIcon trayIcon(ic, &app);
	
	// Setup context menu for tray icon:
	QMenu trayContextMenu;
	trayContextMenu.addAction("Exit TeaMaker Client", &app, SLOT(quit()));
	trayContextMenu.addSeparator();
	trayContextMenu.addAction("Configure...", appObj, SLOT(showConfigDlg()));
	
	trayIcon.setContextMenu(&trayContextMenu);
	trayIcon.show();
	
	qDebug() << "About to execute application";
	
	return app.exec();
}
